<template>
	<swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
		<swiper-item v-for="(item, index) in bannerData" :key="item.id" class="swiper-item">
			<image class="banner-img" :src="item.image" mode="aspectFit" @click="itemHandle(item.jump_type, item.content_description, item.wx_url, item.jump_id)"></image>
		</swiper-item>
	</swiper>
</template>

<script>
	export default {
		data() {
			return {
				indicatorDots: true,
				autoplay: true,
				interval: 3000,
				duration: 500
			}
		},
		props: {
			bannerData: Array
		},
		methods: {
			itemHandle(type, content, url, id) {
				if (type == '列表') {
					if (content === '会员卡') {
						// uni.switchTab({
						// 	url: '/pages/category/category',
						// })
						uni.switchTab({
							url: '/pages/card/list',
						})
						// uni.setStorageSync('categoryIndex', 2)
					} else if (content === '课程') {
						uni.switchTab({
							url: '/pages/schedule/schedule',
						})
						uni.setStorageSync('categoryIndex', 0)
					} else if (content === '商品') {
						uni.switchTab({
							url: '/pages/product/list',
						})
						uni.setStorageSync('categoryIndex', 3)
					} else if (content === '老师') {
						uni.navigateTo({
							url: '/pages/teacher/list/index'
						})
					} else if (content === '公开课') {
						uni.navigateTo({
							url: '/pages/workshop/list',
						})
						//uni.setStorageSync('categoryIndex', 1)
					}else if (content === '直播') {
						uni.navigateTo({
							url: '/pages/live/list'
						})
					} 
				} else if (type == '详情') {
					if (content === '会员卡') {
						uni.navigateTo({
							url: '/pages/card/card?id=' + id
						})
					} else if (content === '课程') {
						uni.navigateTo({
							url: '/pages/course/course?id=' + id
						})
					} else if (content === '商品') {
						uni.navigateTo({
							url: '/pages/product/product?id=' + id
						})
					} else if (content === '老师') {
						uni.navigateTo({
							url: '/pages/teacher/teacher?id=' + id
						})
					} else if (content === '公开课') {
						uni.navigateTo({
							url: '/pages/workshop/workshop?id=' + id
						})
					}
				} else if (type == '公众号文章') {
					uni.navigateTo({
						url: '/pages/at/at?url=' + url,
					})
				} else if (type == '小程序页面') {
					uni.navigateTo({
						url: url
					})
				}
			}
		}
	}
</script>

<style>
	.swiper {
		width: 750rpx;
		height: 400rpx;
	}

	.swiper-item {
		display: block;
		height: 400rpx;
		line-height: 400rpx;
		text-align: center;
	}

	.banner-img {
		width: 720rpx;
		height: 384rpx;
		border-radius: 16rpx;
	}
</style>
